package main

import (
	"flag"
	"multitude-cloud-exporter/pkg/api"
	"multitude-cloud-exporter/pkg/cache"
	"multitude-cloud-exporter/pkg/config"
	"multitude-cloud-exporter/pkg/resource/huawei"
	logger "multitude-cloud-exporter/pkg/util/log"

	"github.com/gin-gonic/gin"
)

var (
	listenAddress = flag.String("listen-address", ":58080", "Address to listen on for web interface and telemetry.")
)

func init() {
	flag.Parse()
	config.Init()
	logger.Init()
	cache.Init()
	huawei.Init(config.Huawei().AK, config.Huawei().SK)
}

func main() {
	logger.Infow("Program start", "env", config.Env, "listen-address", listenAddress)
	engine := gin.Default()
	api.InitRouter(engine)
	logger.Error(engine.Run(*listenAddress))
}
